{load header}
<!--/H-->

    <!-- 内容区 -->
    <div id="main-content">
        <div id="top-alert" class="fixed alert alert-error" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content">这是内容</div>
        </div>
        <div id="main" class="main">
            
            <!-- nav -->
                        <!-- nav -->
            

            
	<div class="main-title">
		<h2>权限列表管理</h2>
	</div>
	<div class="tab-wrap">
		
		<div class="tab-content">
		
	<!-- 表格列表 -->
	<div class="tb-unit posr">
		<div class="tb-unit-bar">
			<a class="btn" href="{eval echo site_url('community/permission_add')}">新增权限</a>
		</div>
		<div class="category">
			<div class="hd cf">
				<div class="fold">折叠</div>
				<div class="name">名称</div>
				<div style="float:right;height:35px;line-height:35px;margin-right:75px;">操作</div>
				<div style="float:right;height:35px;line-height:35px;margin-right:135px;">CODE</div>
				
			</div>
			
			<!--{loop $listtree $val}-->
			
			<dl class="cate-item">
				<dt class="cf">
					<form action="{eval echo site_url('community/permission_edit')}" method="post">
						<div class="btn-toolbar opt-btn cf">
							<input type="text" name="code" class="text input-mid" value="{$val['code']}">
							<a title="编辑" href="{eval echo site_url('community/permission_medit').'?id='.$val['id']}" style="margin: 0 66px 0 21px;">编辑</a>
						</div>
						<div class="fold"><i></i></div>
						<div class="name">
							<span class="tab-sign"></span>
							<input type="hidden" name="id" value="{$val['id']}">
							<input type="text" name="name" class="text" value="{$val['name']}">
							<a class="add-sub-cate" title="添加子分类" href="{eval echo site_url('community/permission_add').'?pid='.$val['id']}">
								<i class="icon-add"></i>
							</a>
							<span class="help-inline msg"></span>
						</div>
					</form>
				</dt>
					<!--{if $val['son']!=''}-->
					<dd>
						<!--{loop $val['son'] $val01}-->
						<dl class="cate-item">
							<dt class="cf">
								<form action="{eval echo site_url('community/permission_edit')}" method="post">
									<div class="btn-toolbar opt-btn cf">
										<input type="text" name="code" class="text input-mid" value="{$val01['code']}">
										<a title="编辑" href="{eval echo site_url('community/permission_medit').'?id='.$val01['id']}" style="margin: 0 66px 0 21px;">编辑</a>
									</div>
									<div class="fold"><i></i></div>
									<div class="name">
										<span class="tab-sign"></span>
										<input type="hidden" name="id" value="{$val01['id']}">
										<input type="text" name="name" class="text" value="{$val01['name']}">
										<span class="help-inline msg"></span>
									</div>
								</form>
							</dt>
						</dl>
						<!--{/loop}-->
					</dd>
					<!--{/if}-->
			</dl>
			
			<!--{/loop}-->
			
		</div>
	</div>
	<!-- /表格列表 -->
	</div>
	</div>
	

<!--F-->{load footer}
	<script type="text/javascript">
		(function($){
			/* 分类展开收起 */
			$(".category dd").prev().find(".fold i").addClass("icon-unfold")
				.click(function(){
					var self = $(this);
					if(self.hasClass("icon-unfold")){
						self.closest("dt").next().slideUp("fast", function(){
							self.removeClass("icon-unfold").addClass("icon-fold");
						});
					} else {
						self.closest("dt").next().slideDown("fast", function(){
							self.removeClass("icon-fold").addClass("icon-unfold");
						});
					}
				});

			/* 三级分类删除新增按钮 */
			$(".category dd dd .add-sub").remove();

			/* 实时更新分类信息 */
			$(".category")
				.on("submit", "form", function(){
					var self = $(this);
					$.post(
						self.attr("action"),
						self.serialize(),
						function(data){
							/* 提示信息 */
							var name = data.status ? "success" : "error", msg;
							msg = self.find(".msg").addClass(name).text(data.info)
									  .css("display", "inline-block");
							setTimeout(function(){
								msg.fadeOut(function(){
									msg.text("").removeClass(name);
								});
							}, 1000);
						},
						"json"
					);
					return false;
				})
                .on("focus","input",function(){
                    $(this).data('param',$(this).closest("form").serialize());

                })
                .on("blur", "input", function(){
                    if($(this).data('param')!=$(this).closest("form").serialize()){
                        $(this).closest("form").submit();
                    }
                });
		})(jQuery);
	</script>
